package EjerciciosNoBoletin2.Ex3;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
//import java.awt.event.KeyAdapter;
//import java.awt.event.KeyEvent;

//import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;


public class VentanaFormulario {

	private Usuario user;
	public VentanaFormulario(Usuario user){
		this.user = user;
		this.montarVentana();
	}
	public static void main(String[] args){
		(new VentanaFormulario(null)).montarVentana();
	}
	
	public void montarVentana(){
		
		JFrame frame = new JFrame();
		JPanel panel1 = new JPanel();
		JPanel panel2 = new JPanel();
		
		JLabel nombre, apellido, dni, edad, profesion;
		JTextField tnombre, tapellido, tdni, tedad, tprofesion;
				
		panel1.setLayout(new GridLayout(5,2));
		
		panel1.add(nombre = new JLabel("Nombre: "));
		panel1.add(tnombre = new JTextField());
		tnombre.setEditable(false);
		tnombre.setText(user.getNombre());
		
		panel1.add(apellido = new JLabel("Apellido: "));
		panel1.add(tapellido = new JTextField());
		tapellido.setEditable(false);
		tapellido.setText(user.getApellido());
		
		panel1.add(dni = new JLabel("DNI: "));
		panel1.add(tdni = new JTextField());
		tdni.setEditable(false);
		tdni.setText(user.getDni());
		
		panel1.add(edad = new JLabel("Edad: "));
		panel1.add(tedad = new JTextField());
		tedad.setEditable(false);
		tedad.setText(String.valueOf(user.getEdad()));

		panel1.add(profesion = new JLabel("Profesion: "));
		panel1.add(tprofesion = new JTextField());
		tprofesion.setEditable(false);
		tprofesion.setText(user.getProfesion());
		
		
		frame.add(panel1, BorderLayout.CENTER);
		frame.add(panel2, BorderLayout.SOUTH);
		
		frame.setDefaultCloseOperation(frame.DISPOSE_ON_CLOSE);
		frame.setSize(new Dimension(430,280));
		frame.setVisible(true);

	}

}
